Java Code Examples for java.util.logging.Level

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project AirReceiver, under directory /src/main/java/org/phlo/AirReceiver/.

Source file: RtpLoggingHandler.java

  18 
vote

@Override public void messageReceived(final ChannelHandlerContext ctx,final MessageEvent evt) throws Exception {
  if (evt.getMessage() instanceof RtpPacket) {
    final RtpPacket packet=(RtpPacket)evt.getMessage();
    final Level level=getPacketLevel(packet);
    if (s_logger.isLoggable(level))     s_logger.log(level,evt.getRemoteAddress() + "> " + packet.toString());
  }
  super.messageReceived(ctx,evt);
}
 

Example 2

From project arquillian-container-was, under directory /was-embedded-8/src/main/java/org/jboss/arquillian/container/was/embedded_8/.

Source file: WebSphereEmbeddedContainer.java

  16 
vote

public void setup(WebSphereEmbeddedContainerConfiguration configuration){
  if (log.isLoggable(Level.FINER)) {
    log.entering(className,"setup");
  }
  this.containerConfiguration=configuration;
  if (log.isLoggable(Level.FINER)) {
    log.exiting(className,"setup");
  }
}
 

Example 3

From project activiti-explorer, under directory /src/main/java/org/activiti/explorer/cache/.

Source file: TrieBasedUserCache.java

  15 
vote

public synchronized void loadUsers(){
  long nrOfUsers=identityService.createUserQuery().count();
  long usersAdded=0;
  userTrie=(RadixTree<List<User>>)ClojureBridge.createEmptyRadixTree();
  userCache=new HashMap<String,User>();
  keyCache=new HashMap<String,List<String>>();
  while (usersAdded < nrOfUsers) {
    if (LOGGER.isLoggable(Level.INFO)) {
      LOGGER.info("Caching users " + usersAdded + " to "+ (usersAdded + 25));
    }
    List<User> users=identityService.createUserQuery().listPage((int)usersAdded,25);
    for (    User user : users) {
      addTrieItem(user);
      addUserCacheItem(user);
      usersAdded++;
    }
  }
}
 

Example 4

From project Activiti-KickStart, under directory /activiti-kickstart-java/src/main/java/org/activiti/kickstart/service/alfresco/.

Source file: AlfrescoKickstartServiceImpl.java

  15 
vote

public String getWorkflowMetaData(String processDefinitionId,String metadataKey){
  String metadataFile=processDefinitionId;
  if (metadataKey.equals(MetaDataKeys.WORKFLOW_JSON_SOURCE)) {
    metadataFile=metadataFile + ".json";
  }
  Document document=getDocumentFromFolder(WORKFLOW_DEFINITION_FOLDER,metadataFile);
  StringBuilder strb=new StringBuilder();
  BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(document.getContentStream().getStream()));
  try {
    String line=bufferedReader.readLine();
    while (line != null) {
      strb.append(line);
      line=bufferedReader.readLine();
    }
  }
 catch (  Exception e) {
    LOGGER.log(Level.SEVERE,"Could not read metadata '" + metadataKey + "' : "+ e.getMessage());
    e.printStackTrace();
  }
 finally {
    if (bufferedReader != null) {
      try {
        bufferedReader.close();
      }
 catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
  return strb.toString();
}
 

Example 5

From project activiti-webapp-rest-generic, under directory /activiti-webapp-rest/src/main/java/org/activiti/rest/api/cycle/.

Source file: ChildNodesGet.java

  15 
vote

@Override protected void execute(ActivitiRequest req,Status status,Cache cache,Map<String,Object> model){
  String artifactId=req.getMandatoryString("artifactId");
  String connectorId=req.getMandatoryString("connectorId");
  try {
    RepositoryNodeCollection children=repositoryService.getChildren(connectorId,artifactId);
    model.put("files",children.getArtifactList());
    model.put("folders",children.getFolderList());
    return;
  }
 catch (  RepositoryException e) {
    log.log(Level.SEVERE,"Cannot load children for id '" + artifactId + "'",e);
  }
  model.put("files",new ArrayList<RepositoryArtifact>());
  model.put("folders",new ArrayList<RepositoryFolder>());
}
 

Example 6

From project AdminCmd, under directory /src/main/java/be/Balor/bukkit/AdminCmd/.

Source file: ACHelper.java

  15 
vote

private boolean addBlackListedItem(final CommandSender sender,final MaterialContainer mat){
  if (mat.isNull()) {
    return false;
  }
  if (!itemBlacklist.add(mat)) {
    final HashMap<String,String> replace=new HashMap<String,String>();
    replace.put("item",mat.display());
    LocaleHelper.BL_ITEM_ALREADY.sendLocale(sender,replace);
    return false;
  }
  final ExtendedConfiguration config=fManager.getYml("blacklist");
  config.set("BlackListedMaterial",itemBlacklist);
  try {
    config.save();
  }
 catch (  final IOException e) {
    DebugLog.INSTANCE.log(Level.WARNING,"Can't save the blacklist",e);
    LocaleHelper.BL_ITEM_PROBLEM.sendLocale(sender);
    return false;
  }
  Utils.sI18n(sender,"addBlacklistItem","material",mat.display());
  return true;
}
 

Example 7

From project AdServing, under directory /modules/utilities/utils/src/main/java/net/mad/ads/base/utils/utils/logging/level/.

Source file: AdLevel.java

  15 
vote

public static Level parse(String level){
  if (level.equalsIgnoreCase(CLICK.getName())) {
    return CLICK;
  }
 else   if (level.equalsIgnoreCase(IMPRESSION.getName())) {
    return IMPRESSION;
  }
  return Level.OFF;
}
 

Example 8

From project advanced, under directory /management/src/main/java/org/neo4j/management/impl/.

Source file: HotspotManagementSupport.java

  15 
vote

private JMXConnectorServer createServer(int port,boolean useSSL){
  MBeanServer server=getMBeanServer();
  final JMXServiceURL url;
  try {
    url=new JMXServiceURL("rmi",null,port);
  }
 catch (  MalformedURLException e) {
    log.log(Level.WARNING,"Failed to start JMX Server",e);
    return null;
  }
  Map<String,Object> env=new HashMap<String,Object>();
  if (useSSL) {
    env.put(RMIConnectorServer.RMI_CLIENT_SOCKET_FACTORY_ATTRIBUTE,new SslRMIClientSocketFactory());
    env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,new SslRMIServerSocketFactory());
  }
  try {
    return JMXConnectorServerFactory.newJMXConnectorServer(url,env,server);
  }
 catch (  IOException e) {
    log.log(Level.WARNING,"Failed to start JMX Server",e);
    return null;
  }
}
 

Example 9

From project AeminiumRuntime, under directory /src/aeminium/runtime/tests/.

Source file: BaseTest.java

  15 
vote

public BaseTest(){
  log=Logger.getLogger(this.getClass().getName());
  Handler conHdlr=new ConsoleHandler();
  conHdlr.setFormatter(new Formatter(){
    public String format(    LogRecord record){
      return "TEST " + record.getLevel() + "  :  "+ record.getMessage()+ "\n";
    }
  }
);
  log.setUseParentHandlers(false);
  log.addHandler(conHdlr);
  log.setLevel(Level.INFO);
}
 

Example 10

From project ajah, under directory /ajah-event-http/src/main/java/com/ajah/log/http/.

Source file: RequestEventHandler.java

  15 
vote

@Override public void run(){
  try {
    this.requestEventManager.save(this.requestEvent);
  }
 catch (  final DataOperationException e) {
    log.log(Level.SEVERE,e.getMessage(),e);
  }
}
 

Example 11

From project almira-sample, under directory /almira-sample-webapp/src/main/java/almira/sample/web/.

Source file: AdminPage.java

  15 
vote

/** 
 * Constructor.
 */
@edu.umd.cs.findbugs.annotations.SuppressWarnings(value={"SE_INNER_CLASS","SIC_INNER_SHOULD_BE_STATIC_ANON"},justification="This is the Wicket way") public AdminPage(){
  super();
  final Label counterLabel=new Label(COUNTER_LABEL_ID,"0");
  add(counterLabel);
  final Label feedbackLabel=new Label(FEEDBACK_LABEL_ID);
  add(feedbackLabel);
  add(new Link<String>("increment_counter_link"){
    @Override public void onClick(){
      final Session session=AdminPage.this.getSession();
      int counterValue=0;
synchronized (session) {
        AtomicInteger counter=(AtomicInteger)session.getAttribute(COUNTER_LABEL_ID);
        if (counter == null) {
          counter=new AtomicInteger();
        }
        counterValue=counter.incrementAndGet();
        session.setAttribute(COUNTER_LABEL_ID,counter);
      }
      counterLabel.setDefaultModel(new Model<Integer>(counterValue));
      LOG.fine("*** Catapult counter value=" + counterValue + " ***");
      feedbackLabel.setDefaultModel(new Model<String>());
    }
  }
);
  add(new Link<String>("rebuild_index"){
    @Override public void onClick(){
      try {
        indexService.rebuildIndex();
        feedbackLabel.setDefaultModel(new Model<String>("Rebuilding index."));
      }
 catch (      Exception e) {
        feedbackLabel.setDefaultModel(new Model<String>("Error rebuilding index!"));
        LOG.log(Level.SEVERE,"Error rebuilding",e);
      }
    }
  }
);
}
 

Example 12

From project AmDroid, under directory /httpclientandroidlib/src/ch/boye/httpclientandroidlib/conn/ssl/.

Source file: AbstractVerifier.java

  15 
vote

/** 
 * Extracts the array of SubjectAlt DNS or IP names from an X509Certificate. Returns null if there aren't any.
 * @param cert X509Certificate
 * @param hostname
 * @return Array of SubjectALT DNS or IP names stored in the certificate.
 */
private static String[] getSubjectAlts(final X509Certificate cert,final String hostname){
  int subjectType;
  if (isIPAddress(hostname)) {
    subjectType=7;
  }
 else {
    subjectType=2;
  }
  LinkedList<String> subjectAltList=new LinkedList<String>();
  Collection<List<?>> c=null;
  try {
    c=cert.getSubjectAlternativeNames();
  }
 catch (  CertificateParsingException cpe) {
    Logger.getLogger(AbstractVerifier.class.getName()).log(Level.FINE,"Error parsing certificate.",cpe);
  }
  if (c != null) {
    for (    List<?> aC : c) {
      List<?> list=aC;
      int type=((Integer)list.get(0)).intValue();
      if (type == subjectType) {
        String s=(String)list.get(1);
        subjectAltList.add(s);
      }
    }
  }
  if (!subjectAltList.isEmpty()) {
    String[] subjectAlts=new String[subjectAltList.size()];
    subjectAltList.toArray(subjectAlts);
    return subjectAlts;
  }
 else {
    return null;
  }
}
 

Example 13

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/aladdin/test/.

Source file: Log.java

  15 
vote

/** 
 * ??Logger??????????
 * @param logger
 * @param level ????????level???????
 * @throws SecurityException
 * @throws IOException
 */
public static void setLogingProperties(Logger logger,Level level){
  FileHandler fh;
  try {
    fh=new FileHandler(getLogName(),true);
    logger.addHandler(fh);
    fh.setFormatter(new SimpleFormatter());
  }
 catch (  SecurityException e) {
    logger.log(Level.SEVERE,"?????",e);
  }
catch (  IOException e) {
    logger.log(Level.SEVERE,"????????",e);
  }
}
 

Example 14

From project and-bible, under directory /jsword-tweaks/src/main/java/jsword/org/crosswire/common/util/.

Source file: Logger.java

  15 
vote

private void doLogging(Level theLevel,String message,Throwable th){
  initialize();
  LogRecord logRecord=new LogRecord(theLevel,message);
  logRecord.setLoggerName(logger.getName());
  logRecord.setSourceClassName(CallContext.getCallingClass(1).getName());
  logRecord.setThrown(th);
  if (showLocation) {
    String methodName=null;
    int lineNumber=-1;
    StackTraceElement[] stack=(new Throwable()).getStackTrace();
    int ix=0;
    while (ix < stack.length) {
      StackTraceElement frame=stack[ix];
      String cname=frame.getClassName();
      if (cname.equals(CLASS_NAME)) {
        break;
      }
      ix++;
    }
    while (ix < stack.length) {
      StackTraceElement frame=stack[ix];
      if (!frame.getClassName().equals(CLASS_NAME)) {
        methodName=frame.getMethodName();
        lineNumber=frame.getLineNumber();
        break;
      }
      ix++;
    }
    logRecord.setSourceMethodName(methodName);
    logRecord.setSequenceNumber(lineNumber);
  }
  System.out.println("JSword:" + message);
  logger.log(logRecord);
}
 

Example 15

From project android-aac-enc, under directory /src/com/googlecode/mp4parser/boxes/mp4/.

Source file: AbstractDescriptorBox.java

  15 
vote

@Override public void _parseDetails(ByteBuffer content){
  parseVersionAndFlags(content);
  data=content.slice();
  content.position(content.position() + content.remaining());
  try {
    data.rewind();
    descriptor=ObjectDescriptorFactory.createFrom(-1,data);
  }
 catch (  IOException e) {
    log.log(Level.WARNING,"Error parsing ObjectDescriptor",e);
  }
catch (  IndexOutOfBoundsException e) {
    log.log(Level.WARNING,"Error parsing ObjectDescriptor",e);
  }
}
 

Example 16

From project android-rackspacecloud, under directory /main/java/net/elasticgrid/rackspace/cloudservers/.

Source file: XMLCloudServers.java

  15 
vote

public Server getServerDetails(int serverID) throws CloudServersException {
  logger.log(Level.INFO,"Retrieving detailed information for server {0}...",serverID);
  validateServerID(serverID);
  HttpGet request=new HttpGet(getServerManagementURL() + "/servers/" + serverID);
  return buildServer(makeRequestInt(request,net.elasticgrid.rackspace.cloudservers.internal.Server.class));
}
 

Example 17

From project android-rindirect, under directory /rindirect/src/main/java/de/akquinet/android/rindirect/.

Source file: Main.java

  15 
vote

/** 
 * Main method. This methods defines the arguments, parse them and launch the R indirection generation.
 * @param args the arguments.
 * @throws ParseException
 * @throws IOException
 */
public static void main(String[] args) throws ParseException, Exception {
  LOGGER.setLevel(Level.WARNING);
  Options options=new Options();
  options.addOption("P","package",true,"destination package (mandatory)").addOption("R","classname",true,"generated java file [R]").addOption("D","destination",true,"the root of the destination [src]").addOption("I","input",true,"R file [searched in the 'gen' folder]").addOption("V","verbose",false,"Enable verbose mode");
  CommandLineParser parser=new PosixParser();
  CommandLine cmd=parser.parse(options,args);
  RIndirect rindirect=configure(cmd);
  rindirect.generate();
}
 

Example 18

From project androidpn, under directory /androidpn-server-src/starter/src/main/java/org/androidpn/server/starter/.

Source file: ServerStarter.java

  15 
vote

public static void main(String[] args){
  try {
    StreamHandler sh=new StreamHandler(System.out,new SimpleFormatter());
    logger.addHandler(sh);
    logger.setLevel(Level.ALL);
    new ServerStarter().start();
  }
 catch (  Exception ex) {
    ex.printStackTrace();
    System.exit(1);
  }
}
 

Example 19

From project android_8, under directory /src/com/google/gson/.

Source file: ParameterizedTypeHandlerMap.java

  15 
vote

public synchronized void registerForTypeHierarchy(Pair<Class<?>,T> pair){
  if (!modifiable) {
    throw new IllegalStateException("Attempted to modify an unmodifiable map.");
  }
  int index=getIndexOfSpecificHandlerForTypeHierarchy(pair.first);
  if (index >= 0) {
    logger.log(Level.WARNING,"Overriding the existing type handler for {0}",pair.first);
    typeHierarchyList.remove(index);
  }
  index=getIndexOfAnOverriddenHandler(pair.first);
  if (index >= 0) {
    throw new IllegalArgumentException("The specified type handler for type " + pair.first + " hides the previously registered type hierarchy handler for "+ typeHierarchyList.get(index).first+ ". Gson does not allow this.");
  }
  typeHierarchyList.add(0,pair);
}
 

Example 20

From project android_external_guava, under directory /src/com/google/common/base/.

Source file: FinalizableReferenceQueue.java

  15 
vote

/** 
 * Constructs a new queue.
 */
@SuppressWarnings("unchecked") public FinalizableReferenceQueue(){
  ReferenceQueue<Object> queue;
  boolean threadStarted=false;
  try {
    queue=(ReferenceQueue<Object>)startFinalizer.invoke(null,FinalizableReference.class,this);
    threadStarted=true;
  }
 catch (  IllegalAccessException e) {
    throw new AssertionError(e);
  }
catch (  Throwable t) {
    logger.log(Level.INFO,"Failed to start reference finalizer thread." + " Reference cleanup will only occur when new references are" + " created.",t);
    queue=new ReferenceQueue<Object>();
  }
  this.queue=queue;
  this.threadStarted=threadStarted;
}
 

Example 21

From project android_external_libphonenumber, under directory /java/src/com/android/i18n/phonenumbers/geocoding/.

Source file: PhoneNumberOfflineGeocoder.java

  15 
vote

private void loadMappingFileProvider(){
  InputStream source=PhoneNumberOfflineGeocoder.class.getResourceAsStream(phonePrefixDataDirectory + "config");
  ObjectInputStream in=null;
  try {
    in=new ObjectInputStream(source);
    mappingFileProvider.readExternal(in);
  }
 catch (  IOException e) {
    LOGGER.log(Level.WARNING,e.toString());
  }
 finally {
    close(in);
  }
}
 

Example 22

From project ANNIS, under directory /annis-service/src/main/java/annis/administration/.

Source file: DefaultAdministrationDao.java

  15 
vote

@SuppressWarnings("unchecked") private String readSqlFromResource(Resource resource,MapSqlParameterSource args){
  Map<String,Object> parameters=args != null ? args.getValues() : new HashMap();
  BufferedReader reader=null;
  try {
    StringBuilder sqlBuf=new StringBuilder();
    reader=new BufferedReader(new InputStreamReader(new FileInputStream(resource.getFile()),"UTF-8"));
    for (String line=reader.readLine(); line != null; line=reader.readLine()) {
      sqlBuf.append(line).append("\n");
    }
    String sql=sqlBuf.toString();
    for (    Entry<String,Object> placeHolderEntry : parameters.entrySet()) {
      String key=placeHolderEntry.getKey();
      String value=placeHolderEntry.getValue().toString();
      log.debug("substitution for parameter '" + key + "' in SQL script: "+ value);
      sql=sql.replaceAll(key,value);
    }
    return sql;
  }
 catch (  IOException e) {
    log.error("Couldn't read SQL script from resource file.",e);
    throw new FileAccessException("Couldn't read SQL script from resource file.",e);
  }
 finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      IOException ex) {
        java.util.logging.Logger.getLogger(DefaultAdministrationDao.class.getName()).log(Level.SEVERE,null,ex);
      }
    }
  }
}
 

Example 23

From project AntiCheat, under directory /src/main/java/net/h31ix/anticheat/.

Source file: Anticheat.java

  15 
vote

@Override public void onEnable(){
  manager=new AnticheatManager(this,getLogger());
  eventList.add(new PlayerListener());
  eventList.add(new BlockListener());
  eventList.add(new EntityListener());
  eventList.add(new VehicleListener());
  setupConfig();
  setupXray();
  setupEvents();
  setupCommands();
  setupUpdater();
  setupMetrics();
  restoreLevels();
  if (verbose) {
    getLogger().log(Level.INFO,"Finished loading.");
  }
}
 

Example 24

From project appengine-java-mapreduce, under directory /java/src/com/google/appengine/tools/mapreduce/impl/handlers/.

Source file: MapReduceServletImpl.java

  15 
vote

/** 
 * Checks to ensure that the current request was sent via an AJAX request. If the request was not sent by an AJAX request, returns false, and sets the response status code to 403. This protects against CSRF attacks against AJAX only handlers.
 * @return true if the request is a task queue request
 */
private static boolean checkForAjax(HttpServletRequest request,HttpServletResponse response){
  if (!"XMLHttpRequest".equals(request.getHeader("X-Requested-With"))) {
    LOG.log(Level.SEVERE,"Received unexpected non-XMLHttpRequest command. Possible CSRF attack.");
    try {
      response.sendError(HttpServletResponse.SC_FORBIDDEN,"Received unexpected non-XMLHttpRequest command.");
    }
 catch (    IOException ioe) {
      throw new RuntimeException("Encountered error writing error",ioe);
    }
    return false;
  }
  return true;
}
 

Example 25

From project archive-commons, under directory /archive-commons/src/main/java/org/archive/extract/.

Source file: ExtractingResourceProducer.java

  15 
vote

public Resource getNext() throws ResourceParseException, IOException {
  Resource current=producer.getNext();
  if (current == null) {
    return null;
  }
  while (true) {
    ResourceFactory f=mapper.mapResourceToFactory(current);
    if (f == null) {
      return current;
    }
    if (LOG.isLoggable(Level.INFO)) {
      LOG.info(String.format("Extracting (%s) with (%s)\n",current.getClass().toString(),f.getClass().toString()));
    }
    current=f.getResource(current.getInputStream(),current.getMetaData(),current.getContainer());
  }
}
 

Example 26

From project Armageddon, under directory /src/main/java/com/iminurnetz/bukkit/plugin/armageddon/.

Source file: ArmageddonPlugin.java

  15 
vote

private void saveCannonsFile(){
  File cache=getCannonsFile();
  File dataDir=cache.getParentFile();
  if (!dataDir.exists()) {
    dataDir.mkdirs();
  }
  try {
    FileOutputStream fos=new FileOutputStream(cache);
    ObjectOutputStream out=new ObjectOutputStream(fos);
    out.writeInt(CANNON_FILE_VERSION);
    out.writeObject(cannons);
    out.writeObject(playerSettings);
    out.close();
    fos.close();
  }
 catch (  Exception e) {
    log(Level.SEVERE,"Cannot cache cannons and settings",e);
  }
}
 

Example 27

From project arquillian-container-gae, under directory /gae-common/src/main/java/org/jboss/arquillian/container/common/.

Source file: AppEngineCommonContainer.java

  15 
vote

/** 
 * Delete app location.
 */
protected void deleteAppLocation(){
  if (appLocation == null)   return;
  try {
    deleteRecursively(appLocation);
  }
 catch (  IOException e) {
    log.log(Level.WARNING,"Cannot delete app location.",e);
  }
 finally {
    appLocation=null;
  }
}
 

Example 28

From project arquillian-container-glassfish, under directory /glassfish-common/src/main/java/org/jboss/arquillian/container/glassfish/clientutils/.

Source file: GlassFishClientUtil.java

  15 
vote

/** 
 * Marshalling a Glassfish Mng API response XML document to a java Map object
 * @param XML document 
 * @return map containing the XML doc representation in java map format
 */
public Map xmlToMap(String document){
  if (document == null) {
    return new HashMap();
  }
  InputStream input=null;
  Map map=null;
  try {
    XMLInputFactory factory=XMLInputFactory.newInstance();
    factory.setProperty(XMLInputFactory.IS_VALIDATING,false);
    input=new ByteArrayInputStream(document.trim().getBytes("UTF-8"));
    XMLStreamReader stream=factory.createXMLStreamReader(input);
    while (stream.hasNext()) {
      int currentEvent=stream.next();
      if (currentEvent == XMLStreamConstants.START_ELEMENT) {
        if ("map".equals(stream.getLocalName())) {
          map=resolveXmlMap(stream);
        }
      }
    }
  }
 catch (  Exception ex) {
    log.log(Level.SEVERE,null,ex);
    throw new RuntimeException(ex);
  }
 finally {
    try {
      input.close();
    }
 catch (    IOException ex) {
      log.log(Level.SEVERE,null,ex);
    }
  }
  return map;
}
 

Example 29

From project arquillian-container-openshift, under directory /openshift-express/src/main/java/org/jboss/arquillian/container/openshift/express/archive/.

Source file: ArchiveUtil.java

  15 
vote

/** 
 * Gets all classes from the archive which implement interface or are the subclass of given needle
 * @param < T > Type of objects to be found
 * @param archive Archive to be searched
 * @param needle Class representing superclass of searched objects
 * @return Unique collection of classes in the archive
 */
public static final <T>Collection<Class<T>> getDefinedClassesOf(Archive<?> archive,Class<T> needle){
  long beforeScanning=System.currentTimeMillis();
  Collection<String> classNames=new LinkedHashSet<String>();
  Collection<Class<T>> needleImpls=new LinkedHashSet<Class<T>>();
  getDefinedClasses(classNames,needleImpls,archive,needle);
  if (log.isLoggable(Level.FINE)) {
    log.fine("Found " + needleImpls + " defined in the archive "+ archive.getName()+ " matching needle "+ needle.getName());
    log.fine("Scanning classpath took " + (System.currentTimeMillis() - beforeScanning) + "ms");
  }
  return needleImpls;
}
 

Example 30

From project arquillian-container-osgi, under directory /container-embedded/src/main/java/org/jboss/arquillian/container/osgi/embedded/.

Source file: EmbeddedDeployableContainer.java

  15 
vote

public void undeploy(Archive<?> archive) throws DeploymentException {
  try {
    Bundle bundle=bundleInst.get();
    if (bundle != null) {
      int state=bundle.getState();
      if (state != Bundle.UNINSTALLED)       bundle.uninstall();
    }
  }
 catch (  BundleException ex) {
    log.log(Level.SEVERE,"Cannot undeploy: " + archive,ex);
  }
}
 

Example 31

From project arquillian-container-tomcat, under directory /tomcat-common/src/main/java/org/jboss/arquillian/container/tomcat/.

Source file: ByteArrayIOUtil.java

  15 
vote

/** 
 * Obtains the contents of the specified stream as a byte array
 * @param in InputStream
 * @throws IllegalArgumentException If the stream was not specified
 * @return the byte[] for the given InputStream
 */
static byte[] asByteArray(final InputStream in) throws IllegalArgumentException {
  if (in == null) {
    throw new IllegalArgumentException("stream must be specified");
  }
  final ByteArrayOutputStream out=new ByteArrayOutputStream(8192);
  final int len=4096;
  final byte[] buffer=new byte[len];
  int read=0;
  try {
    while (((read=in.read(buffer)) != -1)) {
      out.write(buffer,0,read);
    }
  }
 catch (  final IOException ioe) {
    throw new RuntimeException("Error in obtainting bytes from " + in,ioe);
  }
 finally {
    try {
      in.close();
    }
 catch (    final IOException ignore) {
      if (log.isLoggable(Level.FINER)) {
        log.finer("Could not close stream due to: " + ignore.getMessage() + "; ignoring");
      }
    }
  }
  final byte[] content=out.toByteArray();
  return content;
}