use the resource manager
424268
public static void useResource(String host, int port, String user, String password, Authentication authType)
    throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException
  {
    // create the client
    DatabaseClient client = DatabaseClientFactory.newClient(host, port, user, password, authType);

    // create the resource extension client
    HelloWorld hello = new HelloWorld(client);

    String response = hello.sayHello();
    System.out.println("Called hello worlds service, got response:["+ response + "]");

    // release the client
    client.release();
  }
1181163
def add_resource(self, resource):
        """"""
        if resource.exists():
            self.resources[resource] = self.timekeeper.get_indicator(resource)
        else:
            self.resources[resource] = None
262885
def get_resources(cls):
        """"""
        my_plurals = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        attributes.PLURALS.update(my_plurals)
        attr_map = RESOURCE_ATTRIBUTE_MAP
        ext_resources = resource_helper.build_resource_info(my_plurals,
                                                            attr_map,
                                                            constants.A10_CERTIFICATE)

        return ext_resources
1282984
def resources(self):
        
        return sa.orm.relationship(
            "Resource",
            cascade="all",
            passive_deletes=True,
            passive_updates=True,
            backref="owner",
            lazy="dynamic",
        )
544747
def get_resources(cls):
        """"""
        my_plurals = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        attributes.PLURALS.update(my_plurals)
        attr_map = RESOURCE_ATTRIBUTE_MAP
        resources = resource_helper.build_resource_info(my_plurals,
                                                        attr_map,
                                                        constants.A10_DEVICE_INSTANCE)

        return resources
453136
def _resource(resource, pretty: bool = None, **data):
    """"""
    data = clean_data(data)

    ctx = click.get_current_context()
    if ctx.obj.get("env_prefix"):
        data["env_prefix"] = ctx.obj["env_prefix"]

    rsp = resource(**data)
    dump = partial(json.dumps, indent=4) if pretty else partial(json.dumps)
    click.echo(dump(rsp))
408124
def open(self, name, mode='r', *args, **kwargs):
        '''  '''
        fname = self.lookup(name)
        if not fname: raise IOError("Resource %r not found." % name)
        return self.opener(fname, mode=mode, *args, **kwargs)
201221
private void getJavaSource() {
		String[] resourceFiles = new String[getConfigurationFiles().length + 1];
		resourceFiles[0] = getSourceFileName();
		for (int i = 0; i < getConfigurationFiles().length; i++) {
			resourceFiles[i + 1] = getConfigurationFiles()[i];
		}

		GetResourceRequest request = new GetResourceRequest(resourceFiles);
		GwtCommand command = new GwtCommand(GetResourceRequest.COMMAND);
		command.setCommandRequest(request);
		GwtCommandDispatcher.getInstance().execute(command, new AbstractCommandCallback<GetResourceResponse>() {

			public void execute(GetResourceResponse response) {
				if (response.getResources() == null) {
					return;
				}
				showFiles(response.getResources());
			}
		});
	}
32196
def SaveResourceUsage(self, client_id, status):
    """"""
    # Per client stats.
    self.hunt_obj.ProcessClientResourcesStats(client_id, status)
    # Overall hunt resource usage.
    self.UpdateProtoResources(status)
927688
def do_open(self, args):
        """"""

        if not args:
            print('A resource name must be specified.')
            return

        if self.current:
            print('You can only open one resource at a time. Please close the current one first.')
            return

        if args.isdigit():
            try:
                args = self.resources[int(args)][0]
            except IndexError:
                print('Not a valid resource number. Use the command "list".')
                return

        try:
            self.current = self.resource_manager.open_resource(args)
            print('{} has been opened.\n'
                  'You can talk to the device using "write", "read" or "query".\n'
                  'The default end of message is added to each message.'.format(args))

            self.py_attr = []
            self.vi_attr = []
            for attr in getattr(self.current, 'visa_attributes_classes', ()):
                if attr.py_name:
                    self.py_attr.append(attr.py_name)
                self.vi_attr.append(attr.visa_name)

            self.prompt = '(open) '
        except Exception as e:
            print(e)
1207706
def resource(resource_id):
    """"""
    resource_obj = app.db.resource(resource_id)

    if 'raw' in request.args:
        return send_from_directory(os.path.dirname(resource_obj.path),
                                   os.path.basename(resource_obj.path))

    return render_template('resource.html', resource=resource_obj)
655850
def _load_resources(self):
        """"""

        for t in self.doc.find('Root.Table'):
            for c in t.find('Table.Column'):
                if c.get_value('datatype') == 'geometry':
                    c['transform'] = '^empty_str'
                    c['datatype'] = 'text'

        return super()._load_resources()
725367
def handle_resource_not_found(resource):
    
    resource.set_erred()
    resource.runtime_state = ''
    message = 'Does not exist at backend.'
    if message not in resource.error_message:
        if not resource.error_message:
            resource.error_message = message
        else:
            resource.error_message += ' (%s)' % message
    resource.save()
    logger.warning('%s %s (PK: %s) does not exist at backend.' % (
        resource.__class__.__name__, resource, resource.pk))
852785
def install_resources
      FileUtils.mkdir_p(resources_dir)

      installed_resources = []
      resources.each do |file|
        begin
          dst = resources_dir + file.basename
          if file.exist? && !dst.exist?
            FileUtils.cp_r(file, resources_dir)
            installed_resources << dst
          end
        rescue ArgumentError => exc
          unless exc.message =~ /same file/
            raise
          end
        end
      end

      installed_resources
    end
745522
def update_resource(self, resource):
        ''''''
        index = self.resources.index(resource)
        data = {
            'resources__{index}'.format(index=index): resource
        }
        self.update(**data)
        self.reload()
        post_save.send(self.__class__, document=self)
837736
public void activateResourceProtocol ()
    {
        // set up a URL handler so that things can be loaded via urls with the 'resource' protocol
        try {
            AccessController.doPrivileged(new PrivilegedAction<Void>() {
                public Void run () {
                    Handler.registerHandler(ResourceManager.this);
                    return null;
                }
            });
        } catch (SecurityException se) {
            log.info("Running in sandbox. Unable to bind rsrc:// handler.");
        }
    }
925245
function Resource(url, params, actions, options$$1) {

    var self = this || {}, resource = {};

    actions = assign({},
        Resource.actions,
        actions
    );

    each(actions, function (action, name) {

        action = merge({url: url, params: assign({}, params)}, options$$1, action);

        resource[name] = function () {
            return (self.$http || Http)(opts(action, arguments));
        };
    });

    return resource;
}